package com.example.user;

import feign.Logger;
import feign.Request;
import feign.RequestInterceptor;
import feign.Retryer;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackages = "com.example.user.feign")
@MapperScan("com.example.user.mapper")
public class UserApplication {

    @Bean
    Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
    }

    @Bean
    public RequestInterceptor requestInterceptor() {
        return template -> template.header("Accept", "application/json");
    }

    @Bean
    public Retryer feignRetryer() {
        // 重试间隔为100ms，最大重试时间为1s，最多重试3次
        return new Retryer.Default(100, 1000, 3);
    }

    public static void main(String[] args) {
        SpringApplication.run(UserApplication.class, args);
    }
} 